home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / jjbqc.zip / JJBSET.H < prev    next >
C/C++ Source or Header  |  1993-01-04  |  10KB  |  244 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. /****************************************************************************
  7.  *                                                                          *
  8.  *                            jjbset.h                                      *
  9.  *                                                                          *
  10.  *   Copyright (c) 1989, JJB. All rights reserved.                          *
  11.  *                                                                          *
  12.  *   Purpose:                                                               *
  13.  *                                                                          *
  14.  *      The main reason for the get( and set( functions is to provide an    *
  15.  *      easy way to fetch and store integers and characters so they are     *
  16.  *      TRULY GLOBAL for all source and object files linked.                *
  17.  *                                                                          *
  18.  *      The get( and set( functions use less memory and allow you to access *
  19.  *      and change any variable in the entire JJB system.                   *
  20.  *                                                                          *
  21.  *      The second element in each array is permanently reserved for        *
  22.  *      your use only. Actually, each array sets aside  a certain number    *
  23.  *      of elements which you, and only you, are allowed to use.            *
  24.  *                                                                          *
  25.  *     JJB, 9236 church Rd suite 1082, Dallas, Tx 75231 (214) 341-1635      *
  26.  ****************************************************************************/
  27.  
  28. /*
  29. JJB has defined the following arrays as follows:
  30.  
  31.         #define IARRYSIZE  80;
  32.         #define CARRYSIZE  10;
  33.  
  34.         int   iarry[IARRAYSIZE];
  35.        unsigned char  carry[CARRAYSIZE];
  36.  
  37.     The function jjb_initalize(), initalizes the integer and character
  38.     arrays to zero and initalizes some of the variables such as the
  39.     video mode and etc.
  40.  
  41.  
  42.     Each array sets aside  a certain number of bytes for your
  43.     use only. Position [1] in each array is always the first
  44.     position you can use. The advantage is that you can store
  45.     and access integers, characters, long, and pointers from
  46.     any or all of your object modules.
  47.  
  48.  
  49.     You can not access the arrays themselve, but JJB provides you with
  50.     'get(' functions to fetch and 'set(' function to store array values.
  51.  
  52.     Here are some examples:
  53.  
  54.     #define T 1
  55.     #define ESC '\033'
  56.     int x;
  57.     char ch;
  58.     long lnum;
  59.     char *sp;
  60.  
  61.     x = get(VATTRIB);      fetch current attribute for video fast.
  62.         set(UPPER_SW,T);   makes all keyboard input upper case.
  63.  
  64.        ch = getc(KE);          fetch the last key pressed on keyboard.
  65.         setc(KE,ESC);      change last keypress to ESC.
  66.  
  67.      lnum = getl(LFROM);       fetches long from array
  68.         setl(LFROM,lnum);  stores  long in array
  69.  
  70.        sp = getp(EIP);         fetches char pointer from array
  71.         setp(EIP,sp);      stores  char pointer in array
  72.  
  73.  
  74.      In the first example, VATTRIB is defined as 33, so it points to
  75.      the 34th element in the integer array and the instruction get(VATTRIB)
  76.      will return  the value of the current video attribute.
  77.  
  78.  
  79.      You should never have to set this value because JJB provides you
  80.      with higher level functions which give you complete attribute control.
  81.      For example, you can change your program colors by resetting the normal
  82.      color as follows in jjb_setup(): set(VNCOLOR, WHITE ONBLUE);
  83.      The printed documentation explains how easy it is to do.
  84.  
  85. The prototypes are:
  86.  
  87.     int  get(int)           for the integer array
  88.     void set(int, int)
  89.  
  90.     char getc(int)          for the character array
  91.     void setc(int,char)
  92.  
  93.     long getl(int)          for the long array
  94.     void setl(int,long)
  95.  
  96.     char *getp(int)         for the pointer array
  97.     void setp(int,char *)
  98.  
  99. */
  100.  
  101.  
  102. /***************************************************************************
  103.  *                                                                         *
  104.  *                     GET AN INTEGER FROM JJB                             *
  105.  *                     SET AN INTEGER IN JJB                               *
  106.  *                                                                         *
  107.  *  'FROM JJB' means that the integer is stored in JJB.OBJ and not         *
  108.  *  in the file you are using.                                             *
  109.  *                                                                         *
  110.  ***************************************************************************/
  111.  
  112.  
  113. #ifndef IARRYSIZE
  114. #define IARRYSIZE      80
  115. /* 1 thru 29 are reserved for you the C programmer to use as you wish */
  116.  
  117. #define YOUCANUSE1      1
  118. #define YOUCANUSE29    29
  119.  
  120. /* 30 thru 79 are reserved for JJB and are completely described in the
  121.     printed documentation. See JJBREAD.ME.                         */
  122.  
  123. #define UNUSED         30
  124. #define VIDEOMODE      31
  125. #define ONSTK          32
  126.  
  127. #define VATTRIB        33
  128. #define VNCOLOR        34
  129. #define VRCOLOR        35
  130. #define VUCOLOR        36
  131. #define VICOLOR        37
  132. #define VNCOLORMENU    38
  133. #define VRCOLORMENU    39
  134. #define VUCOLORMENU    40
  135. #define VWCOLORMENU    41
  136. #define VEXITATTRIB    42
  137.  
  138. #define IKE            50
  139. #define IKEU           51
  140. #define IKEE           52
  141. #define IKCODE         53
  142.  
  143. #define UPPER_SW       54
  144. #define VCLRW_SW       55
  145. #define F9OFF_SW       56
  146. #define SHOWSETUP_SW   57
  147. #define BEEPOFF_SW     58
  148. #define KK_SW          59
  149. #define NF_SW          60
  150. #define HEADINGOFF_SW  61
  151. #define BOTOFF_SW      62
  152. #define ALTOFF_SW      63
  153.  
  154. /* internal JJB variables and switches enter( functions & JJBENTER.OBJ   */
  155. /* These are completely described in the printed documentation           */
  156. /* You really will have no need to access or change integers 75-79.      */
  157.  
  158. #define EPTR           75
  159. #define ESTART         76
  160. #define EMAX           77
  161. #define EDSP_SW        78
  162. #define ENTER_SW       79
  163.  
  164.  
  165.  
  166. /****************************************************************************
  167.  *                                                                          *
  168.  *                     GET A CHARACTER FROM JJB                             *
  169.  *                     SET A CHARACTER IN JJB                               *
  170.  *                                                                          *
  171.  *   'getc( and setc( are the same as the integer function except they      *
  172.  *   fetch and store characters.                                            *
  173.  *                                                                          *
  174.  *   Do not confuse 'getc(KE)' with 'get_ch()'. The function get_ch() waits *
  175.  *   for a key to be pressed and then stores the values in the character    *
  176.  *   array under the definitions: KE, KEU, KEE and KCODE. get_ch() also     *
  177.  *   stores the integer equivalent in the integer arrays under the          *
  178.  *   definitions: IKE, IKEU, IKEE and IKCODE.                               *
  179.  *                                                                          *
  180.  *   When you 'getc(KEU)', all you are doing is fetching from the character *
  181.  *   array the upper case character of the last keypress. You really do not *
  182.  *   have to concern yourself with these variables because JJB provides you *
  183.  *   with all the input functions you will ever need in the obj files       *
  184.  *   jjbinput.obj and jjbenter.obj.  Plus you can design your own input     *
  185.  *   routines using the JJBENTER.OBJ functions.                             *
  186.  *                                                                          *
  187.  *                                                                          *
  188.  *   char getc(int);          ex:  ch = getc(KE); reads last keypress       *
  189.  *   void setc(int,char);          setc(USERC1,ch); stores char in USERC1   *
  190.  *                                                                          *
  191.  *                                                                          *
  192.  ****************************************************************************/
  193.  
  194. #define CARRYSIZE  10   /* size of the character array */
  195. #define USERC1     81   /* reverved for you the programmer to use       */
  196. #define USERC2     82   /*                "                             */
  197. #define USERC3     83   /*                "                             */
  198. #define KE         84   /* last keypress */
  199. #define KEU        85   /* last keypress taken to upper case */
  200. #define KEE        86   /* if KE = '\0', KEE holds special key value */
  201. #define KCODE      87   /* keyboard scan code */
  202. #define REMOVE     88
  203.  
  204. /* Note: You may be thinking that USERC1 above should be defined as 1,
  205.      instead of 81. You are correct.
  206.  
  207.      However JJB has made it 81 for a reason.
  208.  
  209.      The get( and set( functions check to make sure that the value being
  210.      sent to it is between 0 and 79. If not, an error message will occur.
  211.  
  212.      Therefore if you use 'get(KE)' instead of the proper 'getc(KE)',
  213.      JJB will catch your error.
  214.  
  215.      'getc(' and 'setc('  substracts 80 from the value being sent  to
  216.      it before it fetches or stores a character.
  217.  */
  218.  
  219. #define BLACK   0
  220. #define BLUE    1
  221. #define GREEN   2
  222. #define CYAN    3
  223. #define RED     4
  224. #define MAGENTA 5
  225. #define BROWN   6
  226. #define WHITE   7
  227. #define GRAY    8
  228.  
  229. #define ONBLACK    + 0
  230. #define ONBLUE     + ( BLUE    * 16)
  231. #define ONMAGENTA  + ( MAGENTA * 16)
  232. #define ONGREEN    + ( GREEN   * 16)
  233. #define ONCYAN     + ( CYAN    * 16)
  234. #define ONRED      + ( RED     * 16)
  235. #define ONBROWN    + ( BROWN   * 16)
  236. #define ONWHITE    + ( WHITE   * 16)
  237. #define ONGRAY     + ( GRAY    * 16)
  238. #define MAKEBRIGHT | 8
  239.  
  240. #define T 1
  241. #define DRAWLINE 99
  242. #endif
  243.  
  244.